SELECT items.id, items.title,items.title_eng, items.state, items.hideprice, items.anons, items.price2rub AS price, images.path , 0 + IF(items.title LIKE "%есов%", 40, 0) + IF(items.anons LIKE "%есов%", 5, 0) + IF(items.keywords LIKE "%есов%", 20, 0) + IF(items.comment LIKE "%есов%", 1, 0) + IF(items.title LIKE "%коромысл%", 40, 0) + IF(items.anons LIKE "%коромысл%", 5, 0) + IF(items.keywords LIKE "%коромысл%", 20, 0) + IF(items.comment LIKE "%коромысл%", 1, 0) + IF(items.title LIKE "%вес%", 40, 0) + IF(items.anons LIKE "%вес%", 5, 0) + IF(items.keywords LIKE "%вес%", 20, 0) + IF(items.comment LIKE "%вес%", 1, 0) + IF(items.title LIKE "%цепн%", 40, 0) + IF(items.anons LIKE "%цепн%", 5, 0) + IF(items.keywords LIKE "%цепн%", 20, 0) + IF(items.comment LIKE "%цепн%", 1, 0) + IF(items.title LIKE "%коромыслов%", 40, 0) + IF(items.anons LIKE "%коромыслов%", 5, 0) + IF(items.keywords LIKE "%коромыслов%", 20, 0) + IF(items.comment LIKE "%коромыслов%", 1, 0) as relevance FROM `items` INNER JOIN `images` ON images.id_item=items.id WHERE ((false OR (items.title LIKE "%есов%" OR items.anons LIKE "%есов%" OR items.keywords LIKE "%есов%" OR items.comment LIKE "% есов %") OR (items.title LIKE "%коромысл%" OR items.anons LIKE "%коромысл%" OR items.keywords LIKE "%коромысл%" OR items.comment LIKE "% коромысл %") OR (items.title LIKE "%вес%" OR items.anons LIKE "%вес%" OR items.keywords LIKE "%вес%" OR items.comment LIKE "% вес %") OR (items.title LIKE "%цепн%" OR items.anons LIKE "%цепн%" OR items.keywords LIKE "%цепн%" OR items.comment LIKE "% цепн %") OR (items.title LIKE "%коромыслов%" OR items.anons LIKE "%коромыслов%" OR items.keywords LIKE "%коромыслов%" OR items.comment LIKE "% коромыслов %")) ) AND images.visible=0 AND items.visible=1 AND items.price1_ck=0 AND items.state IN (1,2,3,4,7,9) GROUP BY items.id ORDER BY relevance DESC LIMIT 0,32